# -*- codeing = utf-8 -*-
# @Time : 2021/3/4 21:48
# @Atuthor: 朱朱
# @File: 184文件下载客户端.py
# @Software: PyCharm
import socket

# 1. 建立连接
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 2. 绑定ip和端口号
s.connect(('127.0.0.1', 9090))

# 3. 发送请求数据
file_name = input('请输入您要下载的文件名:')
s.send(file_name.encode('gbk'))

with open(file_name,'wb') as file:
    while True:
        content = s.recv(1024)
        if not content:
            break
        file.write(content)

s.close()